from flask import Flask
from flask_sqlalchemy import SQLAlchemy
# 导入redis数据库
import redis
#导入flask_session扩展，讲session数据保存到Redis中
from flask_session import Session
# 导入数据库迁移模块
from flask_migrate import Migrate, MigrateCommand
# 导入数据库管理
from flask_script import Manager



app = Flask(__name__)

class Config:
    #　设置调试模式
    DEBUG = None
    #　设置秘钥
    SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA"

    # 数据库的配置
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/info32'
    SQLAlCHEMY_TRACK_MODIFICATIONS = False

    # redis配置
    SESSION_TYPE = 'redis'
    # 让 cookie 中的 session_id 被加密签名处理
    SESSION_USE_SIGNER = True
    # 使用redis实例
    SESSION_REDIS = redis.StrictRedis(host='127.0.0.1',port=6379)
    # session 的有效期，单位是秒
    PERMANENT_SESSION_LIFETIME = 86400

app.config.from_object(Config)
# 实例化sqlalchemy对象
db = SQLAlchemy(app)

# 实例化session类
Session(app)

#
manager = Manager(app)
Migrate(app, db)
manager.add_command('db', MigrateCommand)

@app.route('/')
def index():
    return '12'

if __name__ == '__main__':
    app.run()